/*
 * Copyright 2012 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.dspl.validate.violation;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.dspl.model.Identifier;
import com.google.dspl.validate.ItemReference;

import java.util.List;

/**
 * Violation for a concept used as a dimension that doesn't have a definition table.
 *
 * @author Maryla Ustarroz Calonge
 */
public final class DimensionConceptNoDataViolation extends Violation {

  private static final long serialVersionUID = 4293844739068727381L;

  private final Identifier conceptId;

  public DimensionConceptNoDataViolation(ItemReference location, Identifier conceptId) {
    super(Severity.WARNING, location);
    this.conceptId = Preconditions.checkNotNull(conceptId);
  }

  @Override
  public String getDefaultTemplate() {
    return "Concept %s is used as a dimension, but it has no data.";
  }

  @Override
  public List<Object> getDefaultTemplateParameters() {
    return ImmutableList.<Object>of(conceptId);
  }

  public Identifier getConceptId() {
    return conceptId;
  }

  @Override
  public <T> T accept(ViolationVisitor<T> visitor) {
    return visitor.visit(this);
  }
}
